package com.education.model.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;

import com.education.common.constants.EnumConstants;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sun.xml.internal.bind.v2.model.core.EnumConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.checkerframework.common.aliasing.qual.Unique;

/**
 * <p>
 * 
 * </p>
 *
 * @author 余一
 * @since 2021-09-10
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("system_admin")
@ApiModel(value="SystemAdmin对象", description="")
public class SystemAdmin extends BaseEntity<SystemAdmin> {

    @ApiModelProperty(value = "登录名")
    @TableField("login_name")
    @Unique
    private String loginName;

    @ApiModelProperty(value = "密码")
    @TableField("password")
    private String password;

    @ApiModelProperty(value = "密码加密hash")
    @TableField("encrypt")
    private String encrypt;

    @ApiModelProperty(value = "1 是 0 否")
    @TableField("disabled_flag")
    private Integer disabledFlag;

    @ApiModelProperty(value = "登录ip")
    @TableField("login_ip")
    private String loginIp;

    @ApiModelProperty(value = "登录次数")
    @TableField("login_count")
    private Integer loginCount;

    @ApiModelProperty(value = "姓名")
    @TableField("name")
    private String name;

    @ApiModelProperty(value = "最后登录时间")
    @TableField("last_login_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime lastLoginTime;

    @ApiModelProperty(value = "创建类型 （1 系统默认 2. 管理员创建)")
    @TableField("create_type")
    private Integer createType;

    @ApiModelProperty(value = "手机号")
    @TableField("mobile")
    private String mobile;

    @ApiModelProperty(value = "1 是 0 否")
    @TableField("super_flag")
    private Integer superFlag;

    @TableField("ip_address")
    private String ipAddress;

    public Boolean isSupper(){
        return this.superFlag == EnumConstants.Flag.YES.getValue();
    }

    public boolean isDisabled() {
        return this.disabledFlag == EnumConstants.Flag.YES.getValue();
    }
}
